package com.jetty.code;

import com.jetty.server.IServer;
import com.jetty.server.ServerFactory;

public class Jetty {
	private static IServer server;

	public static void start() {
		server = ServerFactory.getServer();
		server.start();
	}

	public static void start(String webAppDir, int port, String context, int scanIntervalSeconds) {
		server = ServerFactory.getServer(webAppDir, port, context, scanIntervalSeconds);
		server.start();
	}

	public static void stop() {
		server.stop();
	}

	/**
	 * Run Jetty Server with Debug Configurations or Run Configurations in Eclipse JavaEE
	 * args example: WebRoot 80 / 5
	 */
	public static void main(String[] args) {
		if (args == null || args.length == 0) {
			server = ServerFactory.getServer();
		} else {
			String webAppDir = args[0];
			int port = Integer.parseInt(args[1]);
			String context = args[2];
			int scanIntervalSeconds = Integer.parseInt(args[3]);
			server = ServerFactory.getServer(webAppDir, port, context, scanIntervalSeconds);
		}
		server.start();
	}
}
